"""
@File         : models.py
@Time         : 2024/05/08 18:08:36
@Author       : Qrj
@Email        : 923207736@qq.com
@Description  : 站内信模板相关数据模型
"""

from datetime import datetime

from sqlalchemy import JSON, BigInteger, Boolean, Column, DateTime, Integer, String

from src.business.admin.system.station_message.enums import (
    StationMessageTypeEnum,
)
from src.models.models import OrmBase


class StationMessageTemplate(OrmBase):
    """站内信模板数据模型"""

    __tablename__ = "system_station_message_template"

    id = Column(BigInteger(), primary_key=True, autoincrement=True, comment="主键")
    name = Column(String(50), nullable=False, unique=True, comment="模板名称")
    content = Column(String(1024), nullable=False, comment="模板内容")
    params = Column(JSON(), nullable=False, default=[], comment="模板参数")
    type = Column(
        String(10),
        nullable=False,
        default=StationMessageTypeEnum.info.value,
        comment="模板类型",
    )
    status = Column(
        Boolean(), default=True, nullable=False, comment="状态"
    )  # (True正常 False停用)
    show_order = Column(
        Integer(), nullable=False, index=True, default=1, comment="显示顺序"
    )
    # 初始模板不允许修改、删除操作
    is_init = Column(Boolean(), nullable=False, default=False, comment="是否初始模板")
    create_datetime = Column(
        DateTime(), nullable=False, default=datetime.now, index=True, comment="创建时间"
    )
    update_datetime = Column(
        DateTime(),
        nullable=False,
        default=datetime.now,
        onupdate=datetime.now,
        index=True,
        comment="修改时间",
    )
    # 创建者用户名
    creator_username = Column(
        String(20), default="", nullable=False, comment="创建者用户名"
    )
    # 修改者用户名
    updater_username = Column(
        String(20), default="", nullable=False, comment="修改者用户名"
    )
